"use strict";

function range(min,max)
{
	return {
		get min() {return min; },
		get max() { return max; },
		include : function(x) {
			return min <= x && x <= max;
		},
		toString : function(){
			return "[" + min + "," + max + "]";
		},
		__iterator__: function(){
			let val = Math.ceil(min);
			return {
				next: function(){
					if(val > max)
					{
						throw StopIteration;
					}
					return val++;
				}
			};
		},
	};
}

for(let i in range(1, 5))
	console.log(i);

let a = range(1,5).__iterator__()
console.log(a.next())
console.log(a.next())
console.log(a.next())
console.log(a.next())
console.log(a.next())
console.log(a.next())
console.log(a.next())

